<template>
  <div>
    <!-- 弹出蒙层规格 -->
    <div id="mengceng" v-if="chuxian">
      <div class="dingwei">
        <div class="shuliang">
          请选择购买数量
          <p class="p6">
            <span class="span0" @click="add"></span><span></span
            ><i>{{num}}</i
            ><em @click="jian"></em>
          </p>
        </div>
        <div>
          <button @click="queren">确认</button>
          <button @click="chuxian=false">取消</button>
        </div>
      </div>
    </div>
    <div id="box">
      <!-- 最顶端部分 -->
      <v-header title="商品详情" :back="true"></v-header>
      <div id="center1">
        <!-- 内容部分 -->
        <div id="neirong">
          <img :src="'http://localhost:3000' + spxq.img" alt="" />
          <div class="jiage">
            <div></div>
            <p class="p1">
              <i
                ><em>￥</em><span>{{ spxq.price }}</span
                ><del>￥{{ spxq.market_price }}</del></i
              >
              <span class="span1"
                ><em class="iconfont">&#xe60f;</em><i>收藏</i></span
              >
            </p>
            <p class="p2">{{ spxq.goodsname }}</p>
            <p class="p3">敏感肌控油，祛痘去写、男女可用、泡沫绵密、净透毛孔</p>
            <span class="p4">11.11限时299元起</span>
            <p class="p5">
              <span>此商品于2020-11-11,00点结束闪购特卖，品牌美妆闪购专场</span>
              <em class="iconfont">查看&#xe601;</em>
            </p>
          </div>
        </div>

        <!-- 内容下面部分 -->
        <div id="ling">
          <div class="nub1">
            <div class="left1">
              <p>领劵</p>
            </div>
            <div class="right1">
              <div class="pp">
                <p class="p1">￥300</p>
                <p class="p2"><i></i></p>
              </div>
              <div class="pp">
                <p class="p1">￥50</p>
                <p class="p2"><i></i></p>
              </div>
              <div class="pp">
                <p class="p1">￥10</p>
                <p class="p2"><i></i></p>
              </div>
            </div>
          </div>
          <div class="nub2">
            <div class="left1">
              <p>分期</p>
            </div>
            <div class="right1">
              <p>可选/3/6/12期</p>
              <p class="iconfont">&#xe601;</p>
            </div>
          </div>
          <div class="nub1">
            <div class="left1">
              <p>领劵</p>
            </div>
            <div class="right1">
              <div class="pp">
                <p class="p1">￥300</p>
                <p class="p2"><i></i></p>
              </div>
              <div class="pp">
                <p class="p1">￥50</p>
                <p class="p2"><i></i></p>
              </div>
              <div class="pp">
                <p class="p1">￥10</p>
                <p class="p2"><i></i></p>
              </div>
            </div>
          </div>
          <div class="nub2">
            <div class="left1">
              <p>分期</p>
            </div>
            <div class="right1">
              <p>可选/3/6/12期</p>
              <p class="iconfont">&#xe601;</p>
            </div>
          </div>
        </div>
      </div>
      <!-- 空内容 -->
      <div id="kong"></div>
      <!-- 底部内容 -->
      <div id="dibu">
        <div class="top1">
          <ul>
            <li class="li1">
              <span class="iconfont">&#xe62d;</span>
              <p>客服</p>
            </li>
            <li>
              <span class="iconfont span1">&#xe663;</span>
              <p>店铺</p>
            </li>
            <li>
              <span class="iconfont">&#xe612;</span>
              <p @click="goShop">购物车</p>
            </li>
          </ul>
          <div class="goumai">
            <input
              type="submit"
              value="加入购物车"
              class="in1"
              @click="jiaru"
            />
            <input type="submit" value="立即购买" class="in2" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import qs from "qs"
export default {
  data() {
    return {
      spxq: {},
      chuxian:false,
      num:1
    };
  },
  mounted() {
    axios({
      url: "/api/getgoodsinfo",
      method: "get",
      params: {
        id: this.$route.params.id,
      },
    }).then((res) => {
      this.spxq = res.data.list[0];
      // this.arr.specsattr=this.arr.specsattr.split(",")
    });
  },
  methods: {
    jiaru() {
      this.chuxian=true
    },
    queren(){
      axios({
        url:"/api/cartadd",
        method:"post",
        data:qs.stringify({
          uid:JSON.parse(localStorage.getItem("userInfo")).uid,
          goodsid: this.spxq.id,
          num:this.num
        }),
        headers:{
          authorization:JSON.parse(localStorage.getItem("userInfo")).token
        }
      }).then(res=>{
        console.log(res);
      })
        this.chuxian=false
    },
    add(){
      this.num++
      this.num=Math.min( this.num,3)
    },
    jian(){
      this.num--
     this.num=Math.max( this.num,1)
    },
    goShop(){
      console.log("我想去购物车");
      // this.$router.push("/shop")
      // this.$router.push("/shop/") 
    }
  },
};
</script>

<style scoped>
.shuliang{
  background: royalblue;
  height: 1rem;
  line-height: 1rem;
  font-size: 0.4rem;
  color: #fff;
}
.dingwei .p6 {
  float: right;
  margin-top: .3rem;
  margin-right: 0.3rem;
  position: relative;
}
.dingwei .p6 em {
  float: right;
  width: 0.28rem;
  height: 0.04rem;
  background: #333;
  margin-top: 0.2rem;
}
.dingwei .p6 i {
  float: right;
  color: #333;
  width: 0.8rem;
  height: 0.4rem;
  background: #f2f2f2;
  margin: 0 0.1rem;
  line-height: 0.4rem;
  text-align: center;
  font-size: 0.2rem;
}
.dingwei .p6 span {
  float: right;
  color: #333;
  width: 0.28rem;
  height: 0.04rem;
  background: #333;
  margin-top: 0.2rem;
}
.dingwei .p6 .span0 {
  transform: rotate(90deg);
  position: absolute;
  right: 0;
}
.dingwei button{
  width:3rem;
  height: 1rem;
  margin:1rem .3rem 0;
}
#mengceng {
  width: 100%;
  height: 100%;
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.dingwei {
  position: fixed;
  bottom: 0;
  background: #fff;
  width: 100%;
  height:5rem;
}
#kong {
  height: 1.5rem;
}
#center1 {
  flex: 1;
  overflow: auto;
  /*内容部分*/
  /*内容下面部分*/
}
#center1 #neirong {
  display: flex;
  flex-direction: column;
}
#center1 #neirong img {
  width: 100%;
}
#center1 #neirong .jiage {
  padding: 0 0.2rem;
}
#center1 #neirong .jiage .p1 {
  margin-top: 0.2rem;
  display: flex;
  justify-content: space-between;
}
#center1 #neirong .jiage .p1 em {
  font-size: 0.2rem;
  color: #ff6040;
}
#center1 #neirong .jiage .p1 span {
  font-size: 0.46rem;
  color: #ff6040;
  margin-right: 0.1rem;
}
#center1 #neirong .jiage .p1 del {
  font-size: 0.2rem;
  color: #979797;
}
#center1 #neirong .jiage .p1 i {
  font-size: 0.2rem;
  color: #ff694b;
}
#center1 #neirong .jiage .p1 .span1 {
  display: flex;
  flex-direction: column;
  align-items: center;
}
#center1 #neirong .jiage .p2 {
  font-size: 0.3rem;
  color: #333;
}
#center1 #neirong .jiage .p3 {
  font-size: 0.26rem;
  color: #a7a7a7;
  margin-bottom: 0.3rem;
}
#center1 #neirong .jiage .p4 {
  font-size: 0.18rem;
  color: #fff6f4;
  padding: 0.08rem;
  background: #ff8066;
}
#center1 #neirong .jiage .p5 {
  color: #a5a5a5;
  background: #f2f2f2;
  padding: 0.08rem 0 0.08rem 0.08rem;
  margin-top: 0.3rem;
  font-size: 0.12rem;
  display: flex;
  justify-content: space-between;
}
#center1 #neirong .jiage .p5 em {
  color: #ff6040;
  font-size: 0.18rem;
}
#center1 #ling .nub1 {
  display: flex;
  justify-content: space-between;
  padding-left: 0.2rem;
  height: 0.9rem;
  line-height: 0.9rem;
}
#center1 #ling .nub1 .left1 p {
  font-size: 0.26rem;
  color: #333;
  font-weight: bold;
  height: 0.26rem;
  line-height: 0.26rem;
  padding-top: 0.4rem;
}
#center1 #ling .nub1 .right1 {
  width: 6.24rem;
  display: flex;
  border-bottom: 2px solid #e6e6e6;
}
#center1 #ling .nub1 .right1 .pp {
  display: flex;
  align-items: center;
  margin-right: 0.2rem;
}
#center1 #ling .nub1 .right1 .pp .p1 {
  background: #ffcc66;
  color: #663014;
  padding: 0.05rem;
  border-right: 1px dashed #b27d3d;
  height: 0.32rem;
  line-height: 0.32rem;
}
#center1 #ling .nub1 .right1 .pp .p2 {
  background: #ffcc66;
  width: 0.14rem;
  height: 0.42rem;
  line-height: 0.42rem;
  position: relative;
}
#center1 #ling .nub1 .right1 .pp .p2 i {
  display: inline-block;
  width: 0.12rem;
  height: 0.12rem;
  border-radius: 50%;
  background-color: #fff;
  position: absolute;
  right: -0.05rem;
  top: 0.15rem;
}
#center1 #ling .nub2 {
  display: flex;
  justify-content: space-between;
  padding-left: 0.2rem;
  height: 0.9rem;
  line-height: 0.9rem;
}
#center1 #ling .nub2 .left1 p {
  font-size: 0.26rem;
  color: #333;
  font-weight: bold;
  height: 0.26rem;
  line-height: 0.26rem;
  padding-top: 0.4rem;
}
#center1 #ling .nub2 .right1 {
  width: 6.24rem;
  display: flex;
  justify-content: space-between;
  padding-top: 0.1rem;
  border-bottom: 2px solid #e6e6e6;
}
#center1 #ling .nub2 .right1 p {
  color: #666666;
}
#center1 #ling .nub2 .right1 .iconfont {
  padding-right: 0.2rem;
}
/*底部内容*/
#dibu {
  height: 1.1rem;
  width: 7.5rem;
  background-color: #fff;
  position: fixed;
  bottom: 0;
}
#dibu .top1 {
  margin-top: 0.1rem;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #ccc;
}
#dibu .top1 ul {
  display: flex;
  justify-content: space-around;
  align-items: center;
  overflow: hidden;
}
#dibu .top1 ul li {
  width: 1.8rem;
  text-align: center;
}
#dibu .top1 ul .iconfont {
  font-size: 0.4rem;
  color: #333;
}
#dibu .top1 ul p {
  font-size: 0.1rem;
  color: #333;
  margin-top: 0.05rem;
}
#dibu .top1 .goumai {
  display: flex;
  flex-direction: row;
}
#dibu .top1 .goumai input {
  width: 2.2rem;
  height: 0.98rem;
  font-size: 0.3rem;
  border: none;
}
#dibu .top1 .goumai .in1 {
  background: #ffcc66;
  color: #663014;
}
#dibu .top1 .goumai .in2 {
  background: #ff6040;
  color: #fff;
}
</style>